package com.example.controller;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.pojo.Salesreturns;
import com.example.pojo.Saleunstorage;
import com.example.service.SalesreturnsBiz;
import com.example.vo.PageBean;

@Controller
@RequestMapping(value="salesre")
public class SalesreturnsAction {
	
	@Autowired
	public SalesreturnsBiz biz;
	
	public SalesreturnsBiz getBiz() {
		return biz;
	}

	public void setBiz(SalesreturnsBiz biz) {
		this.biz = biz;
	}
	
	@RequestMapping("/ind")
	public String index(){ 
		return "xsth" ;
	}
	
	/**
	 * 分页
	 * @param pagenum
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/query")
	@ResponseBody
	public PageBean page(Integer pagenum) throws Exception {
		return biz.findAll(pagenum, 1);
	}
	
	/**
	 * 保存
	 * @param pojo
	 * @throws Exception
	 */
	@RequestMapping("/add")
	@ResponseBody
	public void savesalesre(@RequestBody Salesreturns pojo) throws Exception {
//	    pojo.setBilldate(pojo.getBilldate().substring(0,10)); 
//	    pojo.setPrepayday(pojo.getPrepayday().substring(0,10));
		biz.savesalesreturns(pojo);	
	}
	
	/**
	 * 删除
	 * @param id
	 * @throws Exception
	 */
	@RequestMapping("/del")
	@ResponseBody
	public void delete(String id) throws Exception {
		biz.updatestatus(id);
	}
	
	/**
	 * 加载单号
	 * @param date
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/getid")
	@ResponseBody
	public String loadid(String date) throws Exception {
		return biz.finddate(date);
	}
	
	/**
	 * 查询所有销售出库单
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/querychuku")
	@ResponseBody
	public List<Saleunstorage> findchuku() throws Exception {
		return biz.selectck();
	}
	
	/**
	 * 根据id加载销售出库单
	 * @param ckid
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/loadchuku")
	@ResponseBody
	public Saleunstorage getchuku(String ckid) throws Exception {
		return biz.loadxsck(ckid);
	}
	
	/**
	 * 审核
	 * @param id
	 * @throws Exception
	 */
	@RequestMapping("/thauditing")
	@ResponseBody
	public void auditing(String id) throws Exception {
		biz.auditingSalesreturns(id);
	}
	
	@RequestMapping("/thantiaudit")
	@ResponseBody
	public void antiaudit(String id) throws Exception {
		biz.antiauditSalesreturns(id);
	}
	
}